<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="viewport"
	content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title>邮宝洗衣</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<link href="../../css/type.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
* html .decoration {
	position: absolute;
	right: 16px;
	top: 0;
} /*only for ie*/
/*]]>*/
</style>
<!-- Do not move the bellow script to custom.js! It must stay here to
    load properly! -->
<script type="text/javascript" src="../../scripts/jquery.js"></script>
<script type="text/javascript" src="../../scripts/custom.js" charset="utf-8"></script>
<script type="text/javascript" src="../../scripts/jsAddress.js"></script>
<script type="text/javascript" src="../../scripts/jquerysession.js"></script>
<script type="text/javascript" src="../../scripts/layer/layer.m.js"></script>
</head>
<body onLoad="loadImages()">
	<p class="no-mobile">
		请使用手机访问本页面！ <br /> 这个页面是专门针对手机设计的！
	</p>
	<div class="site">
		<div id="hidepage">
			<p class="center-text">
				加载中，请耐心等待! <br /> <img src="../../images/background/130.gif"
					alt="load">
			</p>
		</div>
		<div class="decoration">
			<div class="back">
				<a href="javascript:void(0)">
					<img src="../../images/home/back.png">
				</a>
			</div> 
			<p class="title" style="width: 33%;float: left;">新增地址</p>
			<div style="width: 33%">
			</div> 
		</div>
	<div id="wrapper">
		<div class="new_addr">
			<div class="person_basemsg" id="row">
				<div class="addr_row">
					<div class="newaddr_title">联系姓名</div>
					<div class="newaddr_data"><input></div>
				</div>
				<div class="addr_row">
					<div class="newaddr_title">联系电话</div>
					<div class="newaddr_data"><input></div>
				</div>
			</div>
			<div class="area_addr" id="row">
				<div class="addr_row">
					<div class="newaddr_title">所在省</div>
					<div class="newaddr_data">
					<select id="province">
						<option>福建省</option>
                    </select>
                    </div>
				</div>
				<div class="addr_row">
					<div class="newaddr_title">所在市</div>
					<div class="newaddr_data">
					<select id="city">
						<option>泉州市</option>
                    </select>
					</div>
				</div>
				<div class="addr_row">
					<div class="newaddr_title">所在区</div>
					<div class="newaddr_data">
					<select id="area" >
						<option>洛江区</option>
						<option>鲤城区</option>
						<option>丰泽区</option>
						<option>晋江桥南片区</option>
                    </select>
					</div>
				</div>
				<div class="addr_row">
					<div class="newaddr_title">所在街道</div>
					<div class="newaddr_data"><input placeholder="街道可为空"></div>
				</div>
			</div>
			<p style="color: red;margin-left:5%">*为了更好的为您服务，详细地址请精确到门牌号</p>
			<div class="detail_addr" id="row">
				<div class="addr_row" style="border-bottom:1.5px solid #a0a0a0;">
					<div class="newaddr_title" style="border-bottom: none">详细地址</div>
					<div class="newaddr_data" style="border-bottom: none"><textarea rows="4" cols="40"  style="width: 98%; resize: none;"></textarea></div>
				</div>
			</div>
			<div class="newaddr_btn" status="0">
				<a href="javascript:void(0)">
					<img src="../../images/person/default_address.png">
				</a>
			</div>
			<div class="newaddr_btn1">
				<a href="javascript:void(0)">
					<img src="../../images/home/complete.png">
				</a>
			</div>
		</div>
	</div>
	</div>
	<script type="text/javascript">
		//addressInit('province', 'city', 'area');
		$(".newaddr_btn1").live("click",function(){
			var data = $(".newaddr_data input");
			var name = $(data[0]).val();
			var mobileNum  = $(data[1]).val();
			var province = $("#province").val(); 
			var city = $("#city").val();
			var area = $("#area").val();
			var street = $(data[2]).val();
			//var addr = $(data[3]).val();
			var addr = $(".newaddr_data textarea").val();
			//alert(addr);
			var status = "${param.status}";
			if(status==""){
				status = $(".newaddr_btn").attr("status");
			}
			var url = "../../transactionRouter?funcID=0009&platformId="+$.session.get("platformId")+"&province="+encodeURI(encodeURI(province))
					+"&city="+encodeURI(encodeURI(city))+"&area="+encodeURI(encodeURI(area))+"&street="+encodeURI(encodeURI(street))+"&addr="+encodeURI(encodeURI(addr))+"&status="+status+"&mobileNum="+mobileNum+"&name="+encodeURI(encodeURI(name));
			if(name==""){layer.open({content: '请输入姓名！',time: 2});return;}
			else if(mobileNum==""){layer.open({content: '请输入手机号码！',time: 2});return;}
			else if(province=="请选择省市"){layer.open({content: '请选择省市！',time: 2});return;}
			//else if(street==""){layer.open({content: '请输入街道！',time: 2});return;}
			else if(addr==""){layer.open({content: '请输入剩余地址信息！',time: 2});return;}
			else if(!validateMobileNum(mobileNum)){layer.open({content: '手机号码格式错误！',time: 2});return;}
			//alert(url);
			$.post(url, function(v) {
				if(v.responseCode=="00000"){
					if($.session.get("totalNum")!=0){
						$.session.set("receiveAddr",province+city+area+street+addr);
						$.session.set("name",name);
						$.session.set("mobileNum",mobileNum);
						layer.open({content: '添加成功！',time: 2,end: function(){location.href = "../home/getcloth.jsp";}});
					}else{
						layer.open({content: '添加成功！',time: 2,end: function(){location.href = "addrmanage.jsp";}});
					}
				}else{
					layer.open({content: '添加失败，请重试！',time: 2});
				}
			});
		});
		$(".newaddr_btn").live("click",function(){
			$(this).attr("status",'2');
			layer.open({content: '设置默认地址成功！',time: 2});
		});
		$(".back").live("click",function(){
			 if($.session.get("totalNum")!=0){
				 location.href = "../home/getcloth.jsp";
			}else{
				location.href = "addrmanage.jsp";
			}
		 });
	</script>
</body>
</html>